/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file    fdcan.h
  * @brief   This file contains all the function prototypes for
  *          the fdcan.c file
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2025 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __FDCAN_H__
#define __FDCAN_H__

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* USER CODE BEGIN Includes */
#include "motor.h"
/* USER CODE END Includes */

extern FDCAN_HandleTypeDef hfdcan1;

/* USER CODE BEGIN Private defines */
// 定义指令类型的枚举
// 电机模式枚举
// typedef enum {
//   MOTOR_MODE_STOP = 0,  // 停止模式
//   MOTOR_MODE_INIT,      // 初始化模式
//   MOTOR_MODE_POSITION,  // 位置模式
//   MOTOR_MODE_TORQUE     // 力矩模式
// } MotorModes;

// 定义 CAN 数据结构体
typedef struct {
  motor_mode_t motorModes;  // 指令类型
  float motorTargets[7];    // 电机 1 到 7 的目标值
} CANMessageData;

typedef struct
{
  FDCAN_RxHeaderTypeDef RxHeader;
  uint8_t RxData[64];
} FDCAN_MessageTypeDef;
/* USER CODE END Private defines */

void MX_FDCAN1_Init(void);

/* USER CODE BEGIN Prototypes */
void FDCAN_ReceiveData(void);

void FDCAN_SendData(uint32_t id, uint8_t *data, uint8_t length);
/* USER CODE END Prototypes */

#ifdef __cplusplus
}
#endif

#endif /* __FDCAN_H__ */

